<template>
	<view>
		<view class="h400">
			<image :src="data.bg_img||''" class="wh-max" mode="aspectFill" />
		</view>
		<view class="p20 pr z-index1" style="margin-top: -200rpx;">
			<view class="mt70 bg-fff radius20 pl20 pr20">
				<u-form>
					<u-form-item>
						<u-input v-model="form.name" placeholder="请填写真实姓名" />
					</u-form-item>
					<u-form-item>
						<u-input v-model="form.mobile" maxlength="11" type="number" placeholder="请填写手机号" />
					</u-form-item>

					<auto-select ref="list" api="/system/basic/getRegion" :apiParams="{level:2}" @confirm="confirm"
						labelName="name" childName="child" valueName="id" />

					<u-form-item>
						<u-input v-model="form.city_name" @click="$refs.list.open()" type="select"
							placeholder="请选择所在地区" />
					</u-form-item>
					<u-form-item>
						<u-input v-model="form.address" placeholder="请输入详细地址" />
					</u-form-item>
				</u-form>
			</view>
			<view class="mb20 color-fs mt20" v-if="data.status==2">拒绝原因:{{data.refuse_cause}}</view>
			<view class="h40"></view>
			<view class="">
				<view class="mb20">备注说明：</view>
				<u-parse :html="data.remark" :domain="$baseUrl" />
			</view>
		</view>
		<view class="h120"></view>
		<view class="pf bottom0 left0 w-max p20 bg-fff">
			<u-button type="warning" @click="submit">{{submit_text()||'提交'}}</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					name: '',
					mobile: '',
					city_id: '',
					city_name: '',
					address: '',
				},
				data: ''
			}
		},
		onLoad(e) {
			this.getData()
			let title = {
				partner: "合伙人",
				master: "陪诊师",
				nurse: "护士",
			}
			uni.setNavigationBarTitle({
				title: '申请' + (title[e.type] || '')
			})
		},
		methods: {
			// /master/team/teamInfo
			getData() {
				this.$request('/master/personal/applyInfo', this.$params).then(res => {
					this.data = res.data
					for (let key in this.form) {
						this.form[key] = res.data[key] ?? this.form[key]
					}
				})
			},
			confirm(e) {
				let item = e[e.length - 1]
				this.form.city_id = item.value
				this.form.city_name = e.map(e => e.label).join(' ')
			},
			submit() {
				let params = {
					...this.$params,
					...this.form,
				}
				this.$request('/master/personal/applyPartner', params).then(res => {
					this.$msg(res.msg)
					this.$navBack(1, 1000)
				})
			},
			submit_text() {
				let obj = {
					0: '申请中',
					1: '已通过',
					2: '已驳回',
				}
				return obj[this.data.status]||''
			},
		}
	}
</script>

<style>

</style>